﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using CRM.Enums;

namespace CRM.Models
{
    [Table("company")]
    [Comment("用户管理_公司信息")]
    [Index(nameof(ParentCompanyId), Name = nameof(ParentCompanyId))]
    [Index(nameof(OemId), Name = nameof(OemId))]
    [Index(nameof(State), Name = nameof(State))]
    public class Company : BaseModel
    {
        //TypeName = "int(11)"
        [Column("id"), Key, Required]
        public int Id { get; set; }
        //TypeName = "int(11)"
        [Column("parent_company_id"), Comment("开通操作公司id"), Required]
        public int ParentCompanyId { get; set; }

        [Column("name", TypeName = "varchar(255)"), Comment("公司名称"), Required]
        public string Name { get; set; }

        [Column("rule_id", TypeName = "int(11)"), Comment("公司权限组id"), Required]
        public int RuleId { get; set; }

        [Column("is_open_user", TypeName = "tinyint"), Comment("允许员工账号无限开1是2否"), Required]
        public IsOpenUsers IsOpenUser { get; set; } = IsOpenUsers.DISABLE;
        public enum IsOpenUsers { None, ENABLE, DISABLE }

        [Column("open_user_num", TypeName = "int(11)"), Comment("允许员工账号开通数量"), Required]
        public int OpenUserNum { get; set; }
        
        [Column("is_unlimited_points", TypeName = "tinyint"), Comment("无限积分1是2否"), Required]
        public IsUnlimitedPointEnum IsUnlimitedPoints { get; set; } = IsUnlimitedPointEnum.DISABLE;
        public enum IsUnlimitedPointEnum { None, ENABLE, DISABLE }

        [Column("number_of_points", TypeName = "int(11)"), Comment("积分数量"), Required]
        public int NumberOfPoints { get; set; }

        [Column("state", TypeName = "tinyint"), Comment("状态1启用2禁用"), Required]
        public States State { get; set; } = States.ENABLE;

        [Column("validity_ids", TypeName = "varchar(255)"), Comment("公司实际有效期 继承过程  有效期id 逗号连接")]
        public string ValidityIds { get; set; }

        [Column("show_validity_id", TypeName = "int(11)"), Comment("展示有效期时间id"), Required]
        public int ShowValidityId { get; set; }

        [Column("show_validity", TypeName = "int(11)"), Comment("展示有效期时间戳"), Required]
        public long ShowValidity { get; set; }

        [Column("creat_ip", TypeName = "varchar(255)"), Comment("创建ip")]
        public string CreatIp { get; set; }

        [Column("oem_id", TypeName = "int(11)"), Comment("贴牌OEM ID"),Required]
        public int OemId { get; set; }

        [Column("show_oem_id", TypeName = "int(11)"), Comment("展示有效期id"),Required]
        public int ShowOemId { get; set; }

        [Column("is_repetition_allowed", TypeName = "tinyint"), Comment("是否允许邮箱（线索）重复")]
        public IsRepetitionAllowedType IsRepetitionAllowed { get; set; } = IsRepetitionAllowedType.DISABLE;
        public enum IsRepetitionAllowedType { DISABLE, ENABLE }

        [Column("auto_waters_day", TypeName = "int"), Comment("自动进入公海天数")]
        public int AutoWatersDay { get; set; } = 15;
    }
}
